package org.jsola.hr.helper;

import org.jsola.hr.dto.TransferAccountsBankDetailAddDTO;
import org.jsola.hr.dto.TransferAccountsBankDetailUpdateDTO;
import org.jsola.hr.entity.TransferAccountsBankDetailDO;
import org.jsola.hr.query.TransferAccountsBankDetailQuery;
import org.jsola.hr.service.ITransferAccountsBankDetailService;
import org.jsola.hr.vo.TransferAccountsBankDetailVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.List;

import static org.jsola.hr.core.AbstractTest.SITE_ID;



/**
 * 转账明细(平安银行)
 *
 * @author zhr
 */
@Component
public class TransferAccountsBankDetailTestHelper extends BaseTestHelper {
    
    @Autowired
    private ITransferAccountsBankDetailService transferAccountsBankDetailService;

    /**
     * 生成add测试数据
     * @return TransferAccountsBankDetailAddDTO
     */
    public TransferAccountsBankDetailAddDTO getTransferAccountsBankDetailAddDTO(){
        TransferAccountsBankDetailAddDTO transferAccountsBankDetailAddDTO = new TransferAccountsBankDetailAddDTO();
        transferAccountsBankDetailAddDTO.setBankBatchId(getRandomValue("varchar",32));
        transferAccountsBankDetailAddDTO.setThirdVoucher(getRandomValue("varchar",20));
        transferAccountsBankDetailAddDTO.setSThirdVoucher(getRandomValue("varchar",20));
        transferAccountsBankDetailAddDTO.setOthBankFlag(getRandomValue("varchar",1));
        transferAccountsBankDetailAddDTO.setOthAreaFlag(getRandomValue("varchar",1));
        transferAccountsBankDetailAddDTO.setIdType(getRandomValue("varchar",5));
        transferAccountsBankDetailAddDTO.setIdNo(getRandomValue("varchar",25));
        transferAccountsBankDetailAddDTO.setOppBankName(getRandomValue("varchar",30));
        transferAccountsBankDetailAddDTO.setOppAccNo(getRandomValue("varchar",30));
        transferAccountsBankDetailAddDTO.setOppAccName(getRandomValue("varchar",32));
        transferAccountsBankDetailAddDTO.setAmount(getRandomValue("varchar",17));
        transferAccountsBankDetailAddDTO.setPostScript(getRandomValue("varchar",30));
        transferAccountsBankDetailAddDTO.setFee(getRandomValue("varchar",17));
        transferAccountsBankDetailAddDTO.setStt(getRandomValue("varchar",6));
        transferAccountsBankDetailAddDTO.setSttInfo(getRandomValue("varchar",64));
        transferAccountsBankDetailAddDTO.setRemarkFcr(getRandomValue("varchar",60));
        return transferAccountsBankDetailAddDTO;
    }


    /**
     * 生成update测试数据
     * @return TransferAccountsBankDetailUpdateDTO
     */
    public TransferAccountsBankDetailUpdateDTO getTransferAccountsBankDetailUpdateDTO(TransferAccountsBankDetailVO transferAccountsBankDetailVO){
        return transferAccountsBankDetailService.selectDOById(transferAccountsBankDetailVO.getId(), SITE_ID).to(TransferAccountsBankDetailUpdateDTO.class);
    }

    /**
     * 生成查询数据
     * @return TransferAccountsBankDetailQuery
     */
    public TransferAccountsBankDetailQuery getTransferAccountsBankDetailQuery() {
        TransferAccountsBankDetailQuery transferAccountsBankDetailQuery = new TransferAccountsBankDetailQuery();
        List<TransferAccountsBankDetailDO> transferAccountsBankDetailDOList = transferAccountsBankDetailService.list(new TransferAccountsBankDetailDO(),SITE_ID);
        if (!CollectionUtils.isEmpty(transferAccountsBankDetailDOList)) {
            TransferAccountsBankDetailDO transferAccountsBankDetailDO = transferAccountsBankDetailDOList.get(0);
            transferAccountsBankDetailQuery = transferAccountsBankDetailDO.to(TransferAccountsBankDetailQuery.class);
        }
        return transferAccountsBankDetailQuery;
    }

    /**
     * 保存示例
     * @return TransferAccountsBankDetailVO
     */
    public TransferAccountsBankDetailVO saveTransferAccountsBankDetailExample(){
        TransferAccountsBankDetailAddDTO addDTO = this.getTransferAccountsBankDetailAddDTO();
        TransferAccountsBankDetailVO transferAccountsBankDetailVO = transferAccountsBankDetailService.save(addDTO,buildTokenUser());
        return transferAccountsBankDetailVO;
    }


}

